<?
/**
 * Cost Admin
 * Пакетник работы с ценами
 * Шаблон
 */
?>
<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<div style="width:100%;float:left;">
<fieldset class="adminform">
    <div style="float:left; width:50%; margin: 0; padding: 0; background-color: #00CCFF;">
        <table class="adminlist" style="width:100%">
            <thead>
                <tr height="35">
                    <th width="5">
                            <?php echo JText::_( 'ID' ); ?>
                    </th>
                    <th>
                        <?php echo JText::_( 'Удалить' ); ?>
                        <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />

                    </th>
                    <th width="230">
                            <?php echo JText::_( 'Ценовой диапазон' ); ?>
                    </th>
                    <th width="100px">
                            <?php echo JText::_( 'Коэффициент' ); ?>
                    </th>
                    <th width="100">
                            <?php echo JText::_( 'Для новых' ); ?>
                    </th>
                    <th width="100">
                            <?php echo JText::_( 'При обновлении' ); ?>
                    </th>
                </tr>
            </thead>
            <? for ($i=0, $n=count( $this->items ); $i < $n; $i++)	{ ?>
            <? $line = &$this->items[$i]; ?>
            <? $checked 	= JHTML::_('grid.id',   $i, $line->id ); ?>
            <tr>
                <td align="center"><?=$line->id;?></td>
                <td align="center"><?php echo $checked; ?></td>
                <td><input type="text" name="price_min[<?=$line->id;?>]" value="<?=$line->price_min;?>" width="50" /> - <input type="text" name="price_max[<?=$line->id;?>]" value="<?=$line->price_max;?>"  width="50" /></td>
                <td><input type="text" name="koef[<?=$line->id;?>]" value="<?=$line->koef;?>" width="50" /></td>
                <td align="center"><input type="checkbox" name="for_new[<?=$line->id;?>]" <?=($line->for_new==1?'checked':'');?> value="1" width="50" /></td>
                <td align="center"><input type="checkbox" name="for_upd[<?=$line->id;?>]" <?=($line->for_upd==1?'checked':'');?> value="1" width="50" /></td>
            </tr>
            <? } ?>
            <tr>
                <td></td>
                <td></td>
                <td><input type="text" name="new_min" value="" width="50" /> - <input type="text" name="new_max" value=""  width="50" /></td>
                <td><input type="text" name="new_koef" value="" width="50" /></td>
                <td><input type="checkbox" name="new_for_new" value="1" width="50" /></td>
                <td><input type="checkbox" name="new_for_upd" value="1" width="50" /></td>
            </tr>
        </table>
    </div>
    <div style="float:left; width:50%; margin: 0; padding: 0; background-color: #00FF00;">
        <table class="adminlist" style="width:100%">
            <thead>
            <tr height="40">
                <th colspan="2">Обновление Цен</th>
            </tr>
            </thead>
            <? for ($i=0, $n=count( $this->items ); $i < $n; $i++)	{ ?>
            <? $line = &$this->items[$i]; ?>
            <tr>
                <td>Обновить диапазон (<?=$line->price_min;?>-<?=$line->price_max;?>):
                <? if (isset($_SESSION['update_cost']['res'][$line->id])) print 'Результат:<br>';
                if (isset($_SESSION['update_cost']['res'][$line->id]))
                    foreach ($_SESSION['update_cost']['res'][$line->id] as $res_msg) { ?>
                    <?=$res_msg;?><br>
                <? } unset ($_SESSION['update_cost']['res'][$line->id]); ?>
                </td>
                <td><input type="button" name="upadate_all_cost" value="Начать" onclick="document.adminForm.update_cost.value='<?=$line->id;?>'; submit();" /></td>
            </tr>
            <? } ?>
            <tr>
                <td>Обновить все цены:
                <? if (isset($_SESSION['update_cost']['res']['all'])) print 'Результат:<br>';
                if (isset($_SESSION['update_cost']['res']['all']))
                foreach ($_SESSION['update_cost']['res']['all'] as $res_msg) { ?>
                    <?=$res_msg;?><br>
                <? } unset ($_SESSION['update_cost']['res']['all']); ?>
                </td>
                <td><input type="button" name="upadate_all_cost" value="Начать" onclick="document.adminForm.update_cost.value='all'; submit();" /></td>
            </tr>
        </table>
    </div>
</fieldset>
</div>
<input type="hidden" name="option" value="com_shop" />
<input type="hidden" name="view" value="cost"/>
<input type="hidden" name="task" value="saveUpdateCost" />
<input type="hidden" name="update_cost" id="update_cost" value="" />
<input type="hidden" name="boxchecked" value="0" />

</form>